function e(component, value) {
    component.$emit("input", value), component.$emit("change", value);
}

(0, require("../common/component").VantComponent)({
    field: !0,
    relation: {
        name: "checkbox-group",
        type: "ancestor",
        linked: function(e) {
            this.parent = e;
        },
        unlinked: function() {
            this.parent = null;
        }
    },
    classes: [ "icon-class", "label-class" ],
    props: {
        value: Boolean,
        disabled: Boolean,
        useIconSlot: Boolean,
        checkedColor: String,
        labelPosition: String,
        labelDisabled: Boolean,
        shape: {
            type: String,
            value: "round"
        }
    },
    methods: {
        emitChange: function(value) {
            this.parent ? this.setParentValue(this.parent, value) : e(this, value);
        },
        toggle: function() {
            var data = this.data, disabled = data.disabled, isChecked = data.value;
            disabled || this.emitChange(!isChecked);
        },
        onClickLabel: function() {
            var data = this.data, labelDisabled = data.labelDisabled, disabled = data.disabled, isChecked = data.value;
            disabled || labelDisabled || this.emitChange(!isChecked);
        },
        setParentValue: function(parent, value) {
            var currentValue = parent.data.value.slice(), checkboxName = this.data.name, maxLimit = parent.data.max;
            if (value) {
                if (maxLimit && currentValue.length >= maxLimit) return;
                -1 === currentValue.indexOf(checkboxName) && (currentValue.push(checkboxName), e(parent, currentValue));
            } else {
                var index = currentValue.indexOf(checkboxName);
                -1 !== index && (currentValue.splice(index, 1), e(parent, currentValue));
            }
        }
    }
});